/*
 * input.h
 *
 *  Created on: May 12, 2010
 *      Author: snirgaz
 */

#ifndef INPUT_H_
#define INPUT_H_
#include "../HelpLibs/def.h"
#include "../HelpLibs/QmcParameters.h"
#include "../HelpLibs/pugixml/pugixml.hpp"
#include "boost/lexical_cast.hpp"
template<typename T>
T readXmlData(pugi::xml_node node, string xmlName) {
	pugi::xml_node foundNode;
	try {
		foundNode = node.child(xmlName.c_str());
		if (foundNode.empty())
			throw(string("Missing Data!" + xmlName));
	} catch (string &error) {
		std::cout << error;
		exit(1);
	}
	return boost::lexical_cast<T>(foundNode.child_value());
}
template<typename T>
T readXmlDataOrDefault(pugi::xml_node node, string xmlName, T def) {
	pugi::xml_node foundNode;
	foundNode = node.child(xmlName.c_str());
	if (foundNode.empty())
		return def;
	else
		return boost::lexical_cast<T>(foundNode.child_value());
}

class InputFile {
private:
	string fileName_;
	QmcParameters qmcParameters_;
public:
	InputFile(string fileName);
	void readFile();
	QmcParameters& getQmcParams();
};

#endif /* INPUT_H_ */
